var restify = require('restify');
var Guest=require("./Controll/GuestControll.js");
var Room=require("./Controll/RoomControll.js");
var Basic=require("./Controll/BasicControll.js");
var MySql=require("./MysqlHelper.js");
function start(){
	var server = restify.createServer();
	server.use(restify.plugins.bodyParser());
	server.use(restify.plugins.queryParser());
	var SqlPool=Object.create(MySql.MysqlHelper);
	SqlPool.InitConnect();
	server.use(function(req,res,next){
		res.charSet('utf-8');
		next();
	})
	Basic.BasicControll(server,SqlPool);
	Guest.GuestControll(server,SqlPool);
	Room.RoomControll(server,SqlPool);
	server.get("/getservertime",function(req,res,next)
	{
		var d = new Date();
		var timestamp = Date.parse(d);
		res.send(timestamp);
	})
	server.listen(5203, function() {
	  console.log('%s listening at %s', server.name, server.url);
	});
}

exports.start=start;